# Use this file to easily define all of your cron jobs.
#
# It's helpful, but not entirely necessary to understand cron before proceeding.
# http://en.wikipedia.org/wiki/Cron

# Example:
#
# set :output, "/path/to/my/cron_log.log"
#
set :output, nil

# it should be staging when in staging environment
# so we should call `whenever -w --set environment=staging` when in staging
# see http://stackoverflow.com/questions/1070231/rails-cron-with-whenever-setting-the-environment
set :environment, :production

every 45.minutes do
  #command "/usr/bin/some_great_command"
  #runner "MyModel.some_method"
  command "echo 'load epg guide '"
  rake "epg:guide:check :environment"
end

every 1.day, :at => '6:30 am' do
  #command "/usr/bin/some_great_command"
  #runner "MyModel.some_method"
  command "echo 'check release '"
  rake "check:release :environment"
end

every 1.day, :at => '0:00 am' do
  #command "/usr/bin/some_great_command"
  #runner "MyModel.some_method"
  command "echo 'empty creditcard'"
  rake "data:creditcard"
end

every 1.day, :at => '4:00 am' do
  #command "/usr/bin/some_great_command"
  #runner "MyModel.some_method"
  command "echo 'account detail info update'"
  rake "data:account_detail_info_update"
end

every 1.day, :at => '0:10 am' do
  #command "/usr/bin/some_great_command"
  #runner "MyModel.some_method"
  command "echo 'update account level'"
  rake "cron:account_level"
  command "echo 'resize log'"
  rake "data:limit[api_visit_log,10000]"
  rake "data:paper_trail_clear"
end

if @environment == 'production'
  every 1.day, :at => '02:00 am' do
    command "cd /root && backup perform --trigger database_backup"
    command "cd /root && backup perform --trigger oa_database_backup"
    command "cd /root && backup perform --trigger files_backup"
  end
end

every 10.minutes do
  rake "data:wifi_check"
end

#
# every 4.days do
#   runner "AnotherModel.prune_old_records"
# end

# Learn more: http://github.com/javan/whenever
